﻿using System.Collections.Generic;
using System.Linq;
using Microsoft.WindowsMobile.PocketOutlook;

namespace SharePointBrowser
{
    public static class PoomHelper
    {
        private static OutlookSession Session = new OutlookSession();

        public static List<Contact> GetAllContacts()
        {
            return Session.Contacts.Items.OfType<Contact>().ToList();
        }

        public static List<Contact> GetContactsWithPicture()
        {
            return Session.Contacts.Items.OfType<Contact>().Where(
            contact => contact.Picture != null).ToList();
        }

        public static void SetContactPicture(Contact contact, string filename)
        {
            contact.SetPicture(filename);
            contact.Update();
        }

        public static void AddContact(Contact contact, string filename)
        {
            Session.Contacts.Items.Add(contact);
            SetContactPicture(contact, filename);
        }

        public static void RemoveContact(Contact contact)
        {
            Session.Contacts.Items.Remove(contact);
        }

    }
}
